package com.tanhua.server.controller;

import com.tanhua.domain.db.PageResult;
import com.tanhua.domain.vo.FriendVo;
import com.tanhua.domain.vo.NearUserVo;
import com.tanhua.domain.vo.UserLocationVo;
import com.tanhua.server.service.UserLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class UserLocationController {
    @Autowired
    private  UserLocationService userLocationService;

    /**
     * 上报地理信息
     */
    @PostMapping("/baidu/location")
    public ResponseEntity saveLocation(@RequestBody Map map) {
        //调用UserLocationService方法
        userLocationService.saveLocation(map);
        //返回状态信息
        return ResponseEntity.ok(null);
    }

    /**
     * 搜附近
     */
    @GetMapping("/tanhua/search")
    public ResponseEntity searchNearby(@RequestParam(required = false)String gender,
                                              @RequestParam(defaultValue = "2000")Long distance) {
        //a.调用service  传入性别和距离的参数 返回List<locationVo>
       List<NearUserVo> nearUserVos= userLocationService.searchNearby(gender,distance);
        //b.返回状态码
        return ResponseEntity.ok(nearUserVos);
    }




}
